//
//  WalletAndSignInViewController.m
//  TerritoryShopkeeper
//
//  Created by 李小龙 on 2017/12/4.
//  Copyright © 2017年 ZDQK. All rights reserved.
//

#import "WalletAndSignInViewController.h"
#import "WalletAndSignInTableViewCell.h"
#import "WalletAndSignInModel.h"
#import "PayView.h"
#import <AlipaySDK/AlipaySDK.h>
#import "MiZhiSendViewController.h"

@interface WalletAndSignInViewController ()<UITableViewDataSource,UITableViewDelegate,DZNEmptyDataSetSource,DZNEmptyDataSetDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (weak, nonatomic) IBOutlet UIView *tableHeader;
@property (weak, nonatomic) IBOutlet UIImageView *tableHeaderImage;
@property (weak, nonatomic) IBOutlet UILabel *tableHeaderTitle;
@property (weak, nonatomic) IBOutlet UILabel *tableHeaderCount;
@property (weak, nonatomic) IBOutlet UIButton *tableHeaderButton;

@property (weak, nonatomic) IBOutlet UIView *tableHeaderBottom;
@property (weak, nonatomic) IBOutlet UILabel *tableHeaderIntegralLabel;
@property (weak, nonatomic) IBOutlet UILabel *tableHeaderCouponLabel;

@property (nonatomic, assign) NSInteger page;
@property (nonatomic, strong) NSMutableArray<WSListModel *> *tableArray;
@property (nonatomic, strong) WalletAndSignInModel *detailModel;
@property (nonatomic, strong) PayView *payView;

@end

@implementation WalletAndSignInViewController
#pragma mark - Get
- (NSMutableArray<WSListModel *> *)tableArray {
    if (!_tableArray) {
        _tableArray = [[NSMutableArray alloc] init];
    }
    return _tableArray;
}
- (PayView *)payView {
    if (!_payView) {
        _payView = [[PayView alloc] initWithFrame:Screen];
    }
    return _payView;
}
#pragma mark - IBAction
- (IBAction)tableHeaderButtonAction:(id)sender {
    // 充值/签到
    switch (self.type) {
        case VCTypeWallet:
        {
            [self walletAction];
        } break;
        case VCTypeSignIn:
        {
            if (!self.tableHeaderButton.selected) {
                [self singinAction];
            } else {
                [MBProgressHUD myShowHUDAddedTo:self.view labelText:@"今天您已签到，请明天再来" animated:YES];
            }
        } break;
        case VCTypeMiZhi:
        {
            MiZhiSendViewController *mizhiVC = [[MiZhiSendViewController alloc] init];
            [self.navigationController pushViewController:mizhiVC animated:YES];
        } break;
        default:
            break;
    }
}
#pragma mark - UIViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self hiddenShadowImage:NO];
    [self createUI];
    
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [MBProgressHUD showHUDProgress:self.view animated:YES];
    [self getWalletData];
}
#pragma mark - action
static NSString *WSTableIdentifier = @"WalletAndSignInTableIdentifier";
- (void)createUI {
    NSString *title, *headerTitle, *headerButtonTitle;
    switch (self.type) {
        case VCTypeWallet:
        {
            title = @"我的钱包";
            headerTitle = @"我的余额";
            headerButtonTitle = @"充值";
        } break;
        case VCTypeSignIn:
        {
            title = @"我的签到";
            headerTitle = @"我的积分";
            headerButtonTitle = @"签到";
            
            [self.tableHeaderButton setTitle:@"已签到" forState:UIControlStateSelected];
            
            [self.tableHeader setHeight:162.0];
            [self.tableHeaderBottom setHidden:YES];
        } break;
        case VCTypeMiZhi:
        {
            title = @"我的米值";
            headerTitle = @"我的米值";
            headerButtonTitle = @"推送";
            
            [self.tableHeader setHeight:162.0];
            [self.tableHeaderBottom setHidden:YES];
        } break;
        default:
            break;
    }
    [self.tableHeaderImage sd_setImageWithURL:GetUrl([UserInfo shareInstance].user.mimg) placeholderImage:PlaceholderImageHeader];
    [self.tableHeaderImage setCircleWithColor:[UIColor whiteColor] borderWidth:2 cornerRadius:self.tableHeaderImage.height/2.0];
    
    self.title = title;
    [self.tableHeaderTitle setText:headerTitle];
    [self.tableHeaderButton setTitle:headerButtonTitle forState:UIControlStateNormal];
    
    // tableView
    self.page = 1;
    [self settingTableViewAdjustment:self.tableView];
    [self.tableView clearExtendCellLine];
    [self.tableView registerNib:[UINib nibWithNibName:@"WalletAndSignInTableViewCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:WSTableIdentifier];
    
    __block typeof(self) blockSelf = self;
    self.tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        blockSelf.page = 1;
        [blockSelf getNetData];
    }];
    self.tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        blockSelf.page++;
        [blockSelf getNetData];
    }];
    [self.tableView.mj_footer setHidden:YES];
}
- (void)uploadHeaderData {
    switch (self.type) {
        case VCTypeWallet:
        {
            [self.tableHeaderCount setText:TextIsNotNil(self.detailModel.wprice)?self.detailModel.wprice:@"0"];
            [self.tableHeaderIntegralLabel setText:TextIsNotNil([UserInfo shareInstance].user.mintegral)?[UserInfo shareInstance].user.mintegral:@"0"];
            [self.tableHeaderCouponLabel setText:TextIsNotNil(self.detailModel.coupon)?self.detailModel.coupon:@"0"];
        } break;
        case VCTypeSignIn:
        {
            NSString *str = [NSString stringWithFormat:@"%@积分",TextIsNotNil([UserInfo shareInstance].user.mintegral)?[UserInfo shareInstance].user.mintegral:@"0"];
            NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:str];
            [attributedStr setAttributes:@{NSFontAttributeName:TextPingFangFontSize(32),
                                           NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(0, str.length-2)];
            [attributedStr setAttributes:@{NSFontAttributeName:TextPingFangFontSize(14),
                                           NSForegroundColorAttributeName:[UIColor whiteColor]                                          } range:[str rangeOfString:@"积分"]];
            [self.tableHeaderCount setAttributedText:attributedStr];
            
            [self.tableHeaderButton setSelected:[UserInfo shareInstance].user.issign];
        } break;
        case VCTypeMiZhi:
        {
            NSString *str = [NSString stringWithFormat:@"%@米值",TextIsNotNil([UserInfo shareInstance].user.mvalue)?[UserInfo shareInstance].user.mvalue:@"0"];
            NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:str];
            [attributedStr setAttributes:@{NSFontAttributeName:TextPingFangFontSize(32),
                                           NSForegroundColorAttributeName:[UIColor whiteColor]} range:NSMakeRange(0, str.length-2)];
            [attributedStr setAttributes:@{NSFontAttributeName:TextPingFangFontSize(14),
                                           NSForegroundColorAttributeName:[UIColor whiteColor]                                          } range:[str rangeOfString:@"米值"]];
            [self.tableHeaderCount setAttributedText:attributedStr];
        } break;
        default:
            break;
    }
}

#pragma mark - 网络请求
- (void)endRefresh {
    [self.tableView.mj_header endRefreshing];
    [self.tableView.mj_footer endRefreshing];
}
- (void)getNetFailure {
    if (_page != 1) {
        _page--;
    }
}
- (void)getNetSuccess:(NSDictionary *)dics {
    
    if ([dics[@"totalRow"] integerValue] > self.tableArray.count) {
        [self.tableView.mj_footer setHidden:NO];
    } else {
        [self.tableView.mj_footer setHidden:YES];
    }
    
    if (self.page == 1) {
        [self.tableArray removeAllObjects];
        [self.tableView.mj_footer resetNoMoreData];
    }
    // 数据列表
    NSArray *listArr = dics[@"data"][@"list"];
    if (listArr.count == 0 && self.page != 1) {
        [self.tableView.mj_footer endRefreshingWithNoMoreData];
        [self getNetFailure];
        return;
    }
    for (NSDictionary *dic in listArr) {
        WSListModel *model = [WSListModel mj_objectWithKeyValues:dic];
        [self.tableArray addObject:model];
    }
    [self.tableView reloadData];
}
- (void)getNetData {
    NSString *url;
    NSDictionary *parameters;
    switch (self.type) {
        case VCTypeWallet:
        {
            url = URL_Get_Wallet_Account;
            parameters = @{@"wid":self.detailModel.wid,@"pageNumber":@(self.page),@"pageSize":PageSize};
        } break;
        case VCTypeSignIn:
        {
            url = URL_Get_Integral;
            parameters = @{@"pageNumber":@(self.page),@"pageSize":PageSize};
        } break;
        case VCTypeMiZhi:
        {
            url = URL_Get_MiZhi_Account;
            parameters = @{@"pageNumber":@(self.page),@"pageSize":PageSize};
        } break;
        default:
            break;
    }
    
    __block typeof(self) blockSelf = self;
    [MYAFNetworking POST:url parameters:parameters success:^(NSURLSessionDataTask * _Nullable task, id  _Nullable responseObject) {
        [MBProgressHUD hideHUDForView:blockSelf.view animated:YES];
        [blockSelf endRefresh];
        if ([responseObject[@"code"] isEqualToString:@"200"]) {
            NSDictionary *dics = responseObject;
            [blockSelf getNetSuccess:dics];
        } else {
            [MBProgressHUD showError:blockSelf.view title:responseObject[@"message"] code:responseObject[@"code"] animated:YES];
            [blockSelf getNetFailure];
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nullable error) {
        [MBProgressHUD hideHUDForView:blockSelf.view animated:YES];
        [MBProgressHUD showError:blockSelf.view title:@"" code:@"" animated:YES];
        [blockSelf endRefresh];
        [blockSelf getNetFailure];
    }];
}
- (void)getWalletData {
    [MYAFNetworking POST:URL_Get_Wallet parameters:nil success:^(NSURLSessionDataTask * _Nullable task, id  _Nullable responseObject) {
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        NSString *code = responseObject[@"code"];
        if ([code isEqualToString:@"200"]) {
            self.detailModel = [WalletAndSignInModel mj_objectWithKeyValues:responseObject[@"data"]];
            [self uploadHeaderData];
            [MBProgressHUD showHUDProgress:self.view animated:YES];
            [self getNetData];
        } else {
            [MBProgressHUD showError:self.view title:responseObject[@"message"] code:code animated:YES];
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nullable error) {
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        [MBProgressHUD showError:self.view title:@"" code:@"" animated:YES];
    }];
}
- (void)singinAction {
    // 签到
    [MBProgressHUD showHUDProgress:self.view animated:YES];
    [MYAFNetworking POST:URL_Save_Integral parameters:nil success:^(NSURLSessionDataTask * _Nullable task, id  _Nullable responseObject) {
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        if ([responseObject[@"code"] isEqualToString:@"200"]) {
            [MBProgressHUD myShowHUDAddedTo:self.view labelText:@"签到成功" animated:YES];
            [self.tableHeaderButton setSelected:YES];
            [UserInfo shareInstance].user.issign = YES;
            [[UserInfo shareInstance] updateUserInterfaceModel:^(BOOL success) {
                [self uploadHeaderData];
                self.page = 1;
                [self getNetData];
            }];
        } else {
            [MBProgressHUD showError:self.view title:responseObject[@"message"] code:responseObject[@"code"] animated:YES];
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nullable error) {
        [MBProgressHUD hideHUDForView:self.view animated:YES];
        [MBProgressHUD showError:self.view title:@"" code:@"" animated:YES];
    }];
}
- (void)walletAction {
    // 充值
    [self.payView.priceLabel setHidden:YES];
    [self.payView.priceTF setHidden:NO];
    
    [self.payView.balanceButton setHidden:YES];
    [self.payView.balanceIcon setHidden:YES];
    [self.payView.balanceTitle setHidden:YES];
    [self.payView.balanceLine setHidden:YES];
    
    [self.payView.titleLabel setText:@"充值"];
    [self.payView.sureButton setTitle:@"确定充值" forState:UIControlStateNormal];
    
    [self.payView showView];
    
    __block typeof(self) blockSelf = self;
    self.payView.block = ^(NSString *payType, NSString *rechargeStr) {
        if (rechargeStr.doubleValue > 0) {
            NSMutableDictionary *dic = [[NSMutableDictionary alloc] initWithObjectsAndKeys:payType,@"type",rechargeStr,@"money", nil];
            [blockSelf rechargeAction:dic];
        }
    };
}
- (void)rechargeAction:(NSMutableDictionary *)dic {
    NSLog(@"%@",dic);
    [MBProgressHUD showHUDProgress:self.view animated:YES];
    __block typeof(self) blockSelf = self;
    [MYAFNetworking POST:URL_Recharge parameters:dic success:^(NSURLSessionDataTask * _Nullable task, id  _Nullable responseObject) {
        [MBProgressHUD hideHUDForView:blockSelf.view animated:YES];
        if ([responseObject[@"code"] isEqualToString:@"200"]) {
            [blockSelf uploadPayOrder:dic[@"type"] omid:responseObject[@"data"]];
        } else {
            [MBProgressHUD showError:blockSelf.view title:responseObject[@"message"] code:responseObject[@"code"] animated:YES];
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nullable error) {
        [MBProgressHUD hideHUDForView:blockSelf.view animated:YES];
        [MBProgressHUD showError:blockSelf.view title:@"" code:@"" animated:YES];
    }];
}

- (void)uploadPayOrder:(NSString *)payType omid:(NSString *)omid {
    NSString *payUrl;
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
    [dic setObject:omid forKey:@"omid"];
    
    if ([payType isEqualToString:@"0"]) {
        payUrl = URL_Pay_Wechat;
    } else if ([payType isEqualToString:@"1"]) {
        payUrl = URL_Pay_Alipay;
    }
    
    __block typeof(self) blockSelf = self;
    [MBProgressHUD showHUDProgress:self.view animated:YES];
    [MYAFNetworking POST:payUrl parameters:dic success:^(NSURLSessionDataTask * _Nullable task, id  _Nullable responseObject) {
        [MBProgressHUD hideHUDForView:blockSelf.view animated:YES];
        if ([responseObject[@"code"] isEqualToString:@"200"]) {
            if ([payType isEqualToString:@"0"]) {
                [blockSelf uploadWechatPay:responseObject[@"data"]];
            } else if ([payType isEqualToString:@"1"]) {
                [blockSelf uploadAlipay:responseObject[@"data"]];
            }
        } else {
            [MBProgressHUD showError:blockSelf.view title:responseObject[@"message"] code:responseObject[@"code"] animated:YES];
        }
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nullable error) {
        [MBProgressHUD hideHUDForView:blockSelf.view animated:YES];
        [MBProgressHUD showError:blockSelf.view title:@"" code:@"" animated:YES];
    }];
}

- (void)uploadAlipay:(NSString *)orderString {
    
    __weak typeof(self) weakSelf = self;
    // NOTE: 调用支付结果开始支付
    [[AlipaySDK defaultService] payOrder:orderString fromScheme:AppScheme callback:^(NSDictionary *resultDic) {
        NSLog(@"reslut = %@",resultDic);
        if ([resultDic[@"resultStatus"] isEqualToString:@"9000"]) {
            //成功
            [MBProgressHUD myShowHUDAddedTo:weakSelf.view labelText:@"充值成功" animated:YES];
            weakSelf.page = 1;
            [weakSelf getWalletData];
        } else {
            [MBProgressHUD myShowHUDAddedTo:weakSelf.view labelText:@"充值失败" animated:YES];
        }
    }];
    
}
- (void)uploadWechatPay:(NSDictionary *)parameters {
    /*
     if (![WXApi isWXAppInstalled]) {
     [MBProgressHUD myShowHUDAddedTo:self.view labelText:@"没有安装微信" animated:YES];
     return;
     }
     if (![WXApi isWXAppSupportApi]) {
     [MBProgressHUD myShowHUDAddedTo:self.view labelText:@"当前微信版本过低" animated:YES];
     return;
     }
     
     PayReq *request   = [[PayReq alloc] init];
     //request.openID    = responseObject[@"data"][@"appId"];
     request.partnerId = Wechat_partnerId;
     request.prepayId  = parameters[@"data"][@"prepayid"];
     request.package   = parameters[@"data"][@"package"];//Sign=WXPay
     request.nonceStr  = parameters[@"data"][@"noncestr"];
     request.timeStamp = [parameters[@"data"][@"timestamp"] unsignedIntValue];
     request.sign      = parameters[@"data"][@"sign"];
     if ([WXApi sendReq:request]) {
     NSLog(@"发送成功");
     if (self.block) {
     self.block(YES);
     }
     } else {
     NSLog(@"发送失败");
     [MBProgressHUD myShowHUDAddedTo:self.view labelText:@"订单获取失败" animated:YES];
     }
     */
}
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.tableArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    WalletAndSignInTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:WSTableIdentifier forIndexPath:indexPath];
    WSListModel *model = self.tableArray[indexPath.row];
    [cell.timeLabel setText:[DateSomeThing getDateStrWithTimestampstr:model.createtime formatStr:@"yyyy-MM-dd HH:mm"]];
    switch (self.type) {
        case VCTypeWallet:
        {
            [cell.titleLabel setText:model.atitle];
            
            NSString *count = [NSString stringWithFormat:@"%@¥%@",model.apaytype.intValue==0?@"+":@"-",model.aprice];
            NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:count];
            [attributedStr setAttributes:@{NSFontAttributeName:TextPingFangMediumFontSize(20),NSForegroundColorAttributeName:[UIColor ThemeColor]} range:NSMakeRange(0, count.length)];
            [attributedStr setAttributes:@{NSFontAttributeName:TextPingFangMediumFontSize(16),NSForegroundColorAttributeName:[UIColor ThemeColor]} range:NSMakeRange(0, 2)];
            
            [cell.countLabel setAttributedText:attributedStr];
        } break;
        case VCTypeSignIn:
        {
            [cell.titleLabel setText:model.ititle];
            
            NSString *count = [NSString stringWithFormat:@"%@%@积分",model.itype.intValue==0?@"+":@"-",model.iintegral];
            NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:count];
            [attributedStr setAttributes:@{NSFontAttributeName:TextPingFangMediumFontSize(20),NSForegroundColorAttributeName:[UIColor ThemeColor]} range:NSMakeRange(0, count.length)];
            [attributedStr setAttributes:@{NSFontAttributeName:TextPingFangMediumFontSize(16),NSForegroundColorAttributeName:[UIColor ThemeColor]} range:NSMakeRange(0, 1)];
            [attributedStr setAttributes:@{NSFontAttributeName:TextPingFangFontSize(12),NSForegroundColorAttributeName:[UIColor ThemeColor]} range:[count rangeOfString:@"积分"]];
            
            [cell.countLabel setAttributedText:attributedStr];
        } break;
        case VCTypeMiZhi:
        {
            [cell.titleLabel setText:model.ititle];
            
            NSString *count = [NSString stringWithFormat:@"%@%@米值",model.itype.intValue==0?@"+":@"-",model.mvalue];
            NSMutableAttributedString *attributedStr = [[NSMutableAttributedString alloc] initWithString:count];
            [attributedStr setAttributes:@{NSFontAttributeName:TextPingFangMediumFontSize(20),NSForegroundColorAttributeName:[UIColor ThemeColor]} range:NSMakeRange(0, count.length)];
            [attributedStr setAttributes:@{NSFontAttributeName:TextPingFangMediumFontSize(16),NSForegroundColorAttributeName:[UIColor ThemeColor]} range:NSMakeRange(0, 1)];
            [attributedStr setAttributes:@{NSFontAttributeName:TextPingFangFontSize(12),NSForegroundColorAttributeName:[UIColor ThemeColor]} range:[count rangeOfString:@"米值"]];
            
            [cell.countLabel setAttributedText:attributedStr];
        } break;
        default:
            break;
    }
    return cell;
}
#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    if (self.type == VCTypeWallet) {
        return 54;
    }
    return 0.001;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    if (self.type == VCTypeWallet) {
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, 54)];
        [view setBackgroundColor:[UIColor whiteColor]];
        
        UIView *grayView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, view.width, 10)];
        [grayView setBackgroundColor:[UIColor backgroundColor]];
        
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, view.width-10, view.height-10)];
        [label setBackgroundColor:[UIColor whiteColor]];
        [label setTextColor:[UIColor blackTextColor]];
        [label setFont:TextPingFangFontSize(14)];
        [label setText:@"余额明细"];
        
        UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(10, view.height-0.5, view.width-20, 0.5)];
        [lineView setBackgroundColor:[UIColor borderColor]];
        
        [view addSubview:label];
        [view addSubview:grayView];
        [view addSubview:lineView];
        
        return view;
    }
    return nil;
}
#pragma mark - DZNEmptyDataSetSource,DZNEmptyDataSetDelegate
//主提示标题
- (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {
    NSString *alertStr = @"暂无签到记录";
    if (self.type == VCTypeWallet) {
        alertStr = @"暂无明细记录";
    } else if (self.type == VCTypeMiZhi) {
        alertStr = @"暂无米值记录";
    }
    return [[NSAttributedString alloc] initWithString:alertStr
                                           attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:16.0],
                                                        NSForegroundColorAttributeName:[UIColor grayTextColor]}];
}
- (void)emptyDataSet:(UIScrollView *)scrollView didTapView:(UIView *)view {
    [MBProgressHUD showHUDProgress:self.view animated:YES];
    _page = 1;
    [self getNetData];
}
- (CGFloat)verticalOffsetForEmptyDataSet:(UIScrollView *)scrollView {
    CGFloat sectionHeaderH;
    if (self.type == VCTypeWallet) {
        sectionHeaderH = 54;
    } else {
        sectionHeaderH = 0;
    }
    return self.tableView.mj_h-(self.tableView.mj_h - (self.tableView.tableHeaderView.mj_h+sectionHeaderH))/2 - self.tableView.mj_h/2;
}
#pragma mark -
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
